#include "../include/threadPool.h"
//  使用小火车传输，小火车的flag默认为-1，小火车的data传输token
int sendToken(int sockfd, char *token){
    train_t train;
    bzero(&train, sizeof(train));
    //  处理token可能为空的情况
    if(token == NULL || *token == '\0'){
        train.length = 0;
        train.data[0] = '\0';
    }else{
        train.length = strlen(token)+1;
        train.flag = -1;
        /* memcpy(train.data,token,train.length); */
        strncpy(train.data,token,train.length);
        /* train.data[train.length] = '\0'; */
    }
    ssize_t ret = send(sockfd, &train, sizeof(train.length)+train.length+sizeof(train.flag),0);
    if(ret < 0){
        perror("sendToken failed");
        return -1;
    }
    return 0;
}
